/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package technotheist.imgcog.filter;

import technotheist.imgcog.image.ImageTemplate;

/**
 *
 * @author Mitch
 */
public class DifferenceOfGaussians extends ConvolveFilter {

    public DifferenceOfGaussians(ImageTemplate img, float sd1, float sd2,
            int radiusB, float weightB) {
        super(new DoGRunner(img, sd1, sd2));
    }

    protected static class DoGRunner extends BiconvolveFilterRunner {

        public DoGRunner(ImageTemplate img, float sd1, float sd2) {
            super(img, false,
                    FilterUtil.getGaussSideLen(sd1),
                    FilterUtil.createGaussianConvolveKernel(sd1),
                    FilterUtil.getGaussSideLen(sd2),
                    FilterUtil.createGaussianConvolveKernel(sd2));
        }

        @Override
        public void run() {
            int x = getGlobalId(0);
            int y = getGlobalId(1);
            //
            int p = 0;
            while (p < imgPixSize) {
                output[imgIndex(x, y, p)] = calcConvolve(x, y, p) - calcSubConvolve(x, y, p);
                p += 1;
            }
        }
    }
}
